<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD><TITLE>Tcl_CreateTimerHandler manual page - Tcl Library Procedures</TITLE>
<link rel="stylesheet" href="../docs.css" type="text/css" media="all">
</HEAD>
<BODY><H2><a href="../contents.htm">Tcl8.6.11/Tk8.6.11 Documentation</a> <small>&gt;</small> <a href="contents.htm">Tcl C API</a> <small>&gt;</small> CrtTimerHdlr</H2>
<H3><A HREF="../UserCmd/contents.htm">Tcl/Tk Applications</A> | <A HREF="../TclCmd/contents.htm">Tcl Commands</A> | <A HREF="../TkCmd/contents.htm">Tk Commands</A> | <A HREF="../ItclCmd/contents.htm">[incr Tcl] Package Commands</A> | <A HREF="../SqliteCmd/contents.htm">SQLite3 Package Commands</A> | <A HREF="../TdbcCmd/contents.htm">TDBC Package Commands</A> | <A HREF="../TdbcmysqlCmd/contents.htm">tdbc::mysql Package Commands</A> | <A HREF="../TdbcodbcCmd/contents.htm">tdbc::odbc Package Commands</A> | <A HREF="../TdbcpostgresCmd/contents.htm">tdbc::postgres Package Commands</A> | <A HREF="../TdbcsqliteCmd/contents.htm">tdbc::sqlite3 Package Commands</A> | <A HREF="../ThreadCmd/contents.htm">Thread Package Commands</A> | <A HREF="../TclLib/contents.htm">Tcl C API</A> | <A HREF="../TkLib/contents.htm">Tk C API</A> | <A HREF="../ItclLib/contents.htm">[incr Tcl] Package C API</A> | <A HREF="../TdbcLib/contents.htm">TDBC Package C API</A></H3>
<DL>
<DD><A HREF="CrtTimerHdlr.htm#M2" NAME="L186">NAME</A>
<DL><DD>Tcl_CreateTimerHandler, Tcl_DeleteTimerHandler &mdash; call a procedure at a given time</DD></DL>
<DD><A HREF="CrtTimerHdlr.htm#M3" NAME="L187">SYNOPSIS</A>
<DL>
<DD><B>#include &lt;tcl.h&gt;</B>
<DD>Tcl_TimerToken
<DD><B>Tcl_CreateTimerHandler</B>(<I>milliseconds, proc, clientData</I>)
<DD><B>Tcl_DeleteTimerHandler</B>(<I>token</I>)
</DL>
<DD><A HREF="CrtTimerHdlr.htm#M4" NAME="L188">ARGUMENTS</A>
<DL class="arguments">
</DL>
<DD><A HREF="CrtTimerHdlr.htm#M5" NAME="L189">DESCRIPTION</A>
<DD><A HREF="CrtTimerHdlr.htm#M6" NAME="L190">SEE ALSO</A>
<DD><A HREF="CrtTimerHdlr.htm#M7" NAME="L191">KEYWORDS</A>
</DL>
<H3><A NAME="M2">NAME</A></H3>
Tcl_CreateTimerHandler, Tcl_DeleteTimerHandler &mdash; call a procedure at a given time
<H3><A NAME="M3">SYNOPSIS</A></H3>
<B>#include &lt;tcl.h&gt;</B><BR>
Tcl_TimerToken<BR>
<B>Tcl_CreateTimerHandler</B>(<I>milliseconds, proc, clientData</I>)<BR>
<B>Tcl_DeleteTimerHandler</B>(<I>token</I>)<BR>
<H3><A NAME="M4">ARGUMENTS</A></H3>
<DL class="arguments">
<DT>int <B>milliseconds</B> (in)<DD>
How many milliseconds to wait before invoking <I>proc</I>.
<P><DT>Tcl_TimerProc <B>*proc</B> (in)<DD>
Procedure to invoke after <I>milliseconds</I> have elapsed.
<P><DT>ClientData <B>clientData</B> (in)<DD>
Arbitrary one-word value to pass to <I>proc</I>.
<P><DT>Tcl_TimerToken <B>token</B> (in)<DD>
Token for previously created timer handler (the return value
from some previous call to <B>Tcl_CreateTimerHandler</B>).
<P></DL>
<H3><A NAME="M5">DESCRIPTION</A></H3>
<B>Tcl_CreateTimerHandler</B> arranges for <I>proc</I> to be
invoked at a time <I>milliseconds</I> milliseconds in the
future.
The callback to <I>proc</I> will be made by <B><A HREF="../TclLib/DoOneEvent.htm">Tcl_DoOneEvent</A></B>,
so <B>Tcl_CreateTimerHandler</B> is only useful in programs that
dispatch events through <B><A HREF="../TclLib/DoOneEvent.htm">Tcl_DoOneEvent</A></B> or through Tcl commands
such as <B><A HREF="../TclCmd/vwait.htm">vwait</A></B>.
The call to <I>proc</I> may not be made at the exact time given by
<I>milliseconds</I>:  it will be made at the next opportunity
after that time.  For example, if <B><A HREF="../TclLib/DoOneEvent.htm">Tcl_DoOneEvent</A></B> is not
called until long after the time has elapsed, or if there
are other pending events to process before the call to
<I>proc</I>, then the call to <I>proc</I> will be delayed.
<P>
<I>Proc</I> should have arguments and return value that match
the type <B>Tcl_TimerProc</B>:
<P>
<PRE>typedef void <B>Tcl_TimerProc</B>(
        ClientData <I>clientData</I>);</PRE>
<P>
The <I>clientData</I> parameter to <I>proc</I> is a
copy of the <I>clientData</I> argument given to
<B>Tcl_CreateTimerHandler</B> when the callback
was created.  Typically, <I>clientData</I> points to a data
structure containing application-specific information about
what to do in <I>proc</I>.
<P>
<B>Tcl_DeleteTimerHandler</B> may be called to delete a
previously created timer handler.  It deletes the handler
indicated by <I>token</I> so that no call to <I>proc</I>
will be made;  if that handler no longer exists
(e.g. because the time period has already elapsed and <I>proc</I>
has been invoked then <B>Tcl_DeleteTimerHandler</B> does nothing.
The tokens returned by <B>Tcl_CreateTimerHandler</B> never have
a value of NULL, so if NULL is passed to <B>Tcl_DeleteTimerHandler</B>
then the procedure does nothing.
<H3><A NAME="M6">SEE ALSO</A></H3>
<B><A HREF="../TclCmd/after.htm">after</A></B>, <B><A HREF="../TclLib/CrtFileHdlr.htm">Tcl_CreateFileHandler</A></B>, <B><A HREF="../TclLib/DoWhenIdle.htm">Tcl_DoWhenIdle</A></B>
<H3><A NAME="M7">KEYWORDS</A></H3>
<A href="../Keywords/C.htm#callback">callback</A>, <A href="../Keywords/C.htm#clock">clock</A>, <A href="../Keywords/H.htm#handler">handler</A>, <A href="../Keywords/T.htm#timer">timer</A>
<div class="copy">Copyright &copy; 1990 The Regents of the University of California.
<BR>Copyright &copy; 1994-1996 Sun Microsystems, Inc.
</div>
</BODY></HTML>
